global tempoTeste

T = 0.1;
%% Maximos e minimos: nivel e sinal de controle
nivelMAX = 30;
nivelMIN = 0;
sinalContMAX = 3;%a1/Km*sqrt(2*g*nivelMAX);
sinalContMIN = -3;%a1/Km*sqrt(2*g*nivelMIN);

%% Range: nivel e sinal de controle
rangeNivel = nivelMAX - nivelMIN;
rangeCV = sinalContMAX - sinalContMIN;

%% Coletando dados
tempo = saidaMA(:,1);
CV = saidaMA(:,2);
tank2 = saidaMA(:,3);

%% FAIXA 1

t1 = tempo(1:40/T);
T2_1 = tank2(1:40/T);
CV_1 = CV(1:40/T);

deltaT2_1 = T2_1(end) - T2_1(1);
deltaCV_1 = CV_1(end) - CV_1(1);
deltaT2_1_norm = deltaT2_1/rangeNivel;
deltaCV_1_norm = deltaCV_1/rangeCV;

K1 = deltaT2_1%/deltaCV_1;
% K1 = deltaT2_1_norm/deltaCV_1_norm;

if T2_1(end) > T2_1(1)
    lim = 0.04;
    theta1 = t1(min(find(T2_1>lim)))-t1(1)
else
    lim = 0.95*T2_1(1);
    theta1 = t1(min(find(T2_1<lim)))-t1(1)
end

aux = T2_1(1)+ (0.632*deltaT2_1);
index = min( find(T2_1 > aux) );
tal1 = t1(index)-t1(1)-theta1
